package org.rslai.tcedit.conf.impl;

import org.rslai.tcedit.conf.AutoTestConf;
import org.rslai.util.env.EnvVariable;

/**
 * AutoTest 配置信息实现类
 * 
 * @author rslai
 * 
 * @spring.bean id="autoTestConf"
 */
public class AutoTestConfImpl implements AutoTestConf {
	private String driver = "";
	private String homeDir;
	private String scriptDir;
	private String resourcesDir;
	private String reportDir;
	private String environmentDir;
	
	/**
	 * @spring.property value="${autotest.home.dir}"
	 */
	public void setHomeDir(String homeDir) {
		this.homeDir = org.rslai.util.io.File.getInstance().getAbsolutePath(homeDir);

		if (EnvVariable.getInstance().getOsName().indexOf("Windows") != -1) {
			int i = this.homeDir.indexOf(':') + 1;
			if (i <= this.homeDir.length()) {
				this.driver = this.homeDir.substring(0, i);
			}
		}
	}

	/**
	 * @spring.property value="${autotest.script.dir}"
	 */
	public void setScriptDir(String scriptDir) {
		this.scriptDir = this.homeDir + org.rslai.util.env.EnvVariable.getInstance().getFileSeparator() + scriptDir;
		this.scriptDir = org.rslai.util.io.File.getInstance().getAbsolutePath(this.scriptDir);
	}

	/**
	 * @spring.property value="${autotest.resources.dir}"
	 */
	public void setResourcesDir(String resourcesDir) {
		this.resourcesDir = resourcesDir;
	}

	/**
	 * @spring.property value="${autotest.report.dir}"
	 */
	public void setReportDir(String reportDir) {
		this.reportDir = reportDir;
	}

	/**
	 * @spring.property value="${autotest.environment.dir}"
	 */
	public void setEnvironmentDir(String environmentDir) {
		this.environmentDir = this.homeDir + org.rslai.util.env.EnvVariable.getInstance().getFileSeparator() + environmentDir;
		this.environmentDir = org.rslai.util.io.File.getInstance().getAbsolutePath(this.environmentDir);
	}

	@Override
	public String getDriver() {
		return this.driver;
	}

	@Override
	public String getHomeDir() {
		return this.homeDir;
	}

	@Override
	public String getScriptDir() {
		return this.scriptDir;
	}

	@Override
	public String getResourcesDir() {
		return this.resourcesDir;
	}

	@Override
	public String getReportDir() {
		return this.reportDir;
	}

	@Override
	public String getEnvironmentDir() {
		return this.environmentDir;
	}

}
